﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace WCS.Infrastructure.EFCore;

/// <summary>
/// 易票联分账记录表
/// </summary>
[Table("EpaylinksSplitRecord")]
[Index("MerchantId", Name = "idx_EpaylinksSplitRecord_MerchantId")]
[Index("OutTradeNo", Name = "idx_EpaylinksSplitRecord_OutTradeNo", IsUnique = true)]
[Index("RequestTime", Name = "idx_EpaylinksSplitRecord_RequestTime")]
[Index("SplitStatus", Name = "idx_EpaylinksSplitRecord_SplitStatus")]
[Index("SplitTransactionNo", Name = "idx_EpaylinksSplitRecord_SplitTransactionNo")]
[Index("TransactionNo", Name = "idx_EpaylinksSplitRecord_TransactionNo")]
[Index("UserId", Name = "idx_EpaylinksSplitRecord_UserId")]
public partial class EpaylinksSplitRecord
{
    /// <summary>
    /// 分账记录ID
    /// </summary>
    [Key]
    [StringLength(32)]
    public string Id { get; set; } = null!;

    /// <summary>
    /// 商户订单号（分账订单号）
    /// </summary>
    [StringLength(64)]
    public string OutTradeNo { get; set; } = null!;

    /// <summary>
    /// 商户编号
    /// </summary>
    [StringLength(32)]
    public string CustomerCode { get; set; } = null!;

    /// <summary>
    /// 商户ID
    /// </summary>
    [StringLength(32)]
    public string MerchantId { get; set; } = null!;

    /// <summary>
    /// 用户ID
    /// </summary>
    [StringLength(32)]
    public string UserId { get; set; } = null!;

    /// <summary>
    /// 分账金额，单位为分
    /// </summary>
    public long Amount { get; set; }

    /// <summary>
    /// 手续费，单位为分
    /// </summary>
    public long Fee { get; set; }

    /// <summary>
    /// 实际提现金额，单位为分
    /// </summary>
    public long ActualAmount { get; set; }

    /// <summary>
    /// 费率
    /// </summary>
    public decimal FeeRate { get; set; }

    /// <summary>
    /// 分账状态：0=处理中,1=分账成功,2=分账失败,3=预分帐成功，4=已撤销，5=待处理
    /// </summary>
    public int SplitStatus { get; set; }

    /// <summary>
    /// 易票联订单号
    /// </summary>
    [StringLength(64)]
    public string? TransactionNo { get; set; }

    /// <summary>
    /// 易票联分账单号
    /// </summary>
    [StringLength(64)]
    public string? SplitTransactionNo { get; set; }

    /// <summary>
    /// 商户分账单号
    /// </summary>
    [StringLength(64)]
    public string? OutSplitTradeNo { get; set; }

    /// <summary>
    /// 撤销单号
    /// </summary>
    [StringLength(64)]
    public string? RevokeTransactionNo { get; set; }

    /// <summary>
    /// 实际分账金额
    /// </summary>
    public long? RealAmount { get; set; }

    /// <summary>
    /// 分账结果（00=分账成功，01=分账失败，03=处理中，04=预分帐成功，05=已撤销，51=待处理）
    /// </summary>
    [StringLength(2)]
    public string? SplitState { get; set; }

    /// <summary>
    /// 分账请求时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime RequestTime { get; set; }

    /// <summary>
    /// 分账完成时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime? SplitTime { get; set; }

    /// <summary>
    /// 回调接收时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime? CallbackTime { get; set; }

    /// <summary>
    /// 请求参数JSON
    /// </summary>
    [Column(TypeName = "jsonb")]
    public string? RequestData { get; set; }

    /// <summary>
    /// 回调参数JSON
    /// </summary>
    [Column(TypeName = "jsonb")]
    public string? CallbackData { get; set; }

    /// <summary>
    /// 请求后响应JSON
    /// </summary>
    [Column(TypeName = "jsonb")]
    public string? ApiResponse { get; set; }

    /// <summary>
    /// 商户备注
    /// </summary>
    [StringLength(512)]
    public string? AttachData { get; set; }

    /// <summary>
    /// 通知地址
    /// </summary>
    [StringLength(512)]
    public string? NotifyUrl { get; set; }

    /// <summary>
    /// 随机字符串
    /// </summary>
    [StringLength(64)]
    public string? NonceStr { get; set; }

    /// <summary>
    /// 扩展属性
    /// </summary>
    public string? ExtraProperties { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime CreationTime { get; set; }

    /// <summary>
    /// 最后修改时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime? LastModificationTime { get; set; }

    /// <summary>
    /// 分账手续费（单位为分）
    /// </summary>
    public long? ProcedureFee { get; set; }

    /// <summary>
    /// 分账商户编号
    /// </summary>
    [StringLength(32)]
    public string? MemberId { get; set; }
}
